package com.medical.project.system.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.medical.framework.aspectj.lang.annotation.Log;
import com.medical.framework.aspectj.lang.enums.BusinessType;
import com.medical.project.system.domain.TBxRecord;
import com.medical.project.system.service.ITBxRecordService;
import com.medical.framework.web.controller.BaseController;
import com.medical.framework.web.domain.AjaxResult;
import com.medical.common.utils.poi.ExcelUtil;
import com.medical.framework.web.page.TableDataInfo;

/**
 * 慢性报销管理Controller
 *
 * @author ruoyi
 * @date 2020-06-16
 */
@RestController
@RequestMapping("/system/record")
public class TBxRecordController extends BaseController {
    @Autowired
    private ITBxRecordService tBxRecordService;


    /**
     * 查询慢性报销管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBxRecord tBxRecord) {
        startPage();
        List<TBxRecord> list = tBxRecordService.selectTBxRecordList(tBxRecord);
        return getDataTable(list);
    }

    /**
     * 导出慢性报销管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:export')")
    @Log(title = "慢性报销管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TBxRecord tBxRecord) {
        List<TBxRecord> list = tBxRecordService.selectTBxRecordList(tBxRecord);
        ExcelUtil<TBxRecord> util = new ExcelUtil<TBxRecord>(TBxRecord.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取慢性报销管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tBxRecordService.selectTBxRecordById(id));
    }

    /**
     * 新增慢性报销管理
     */
    @PreAuthorize("@ss.hasPermi('system:record:add')")
    @Log(title = "慢性报销管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBxRecord tBxRecord) {
        return toAjax(tBxRecordService.insertTBxRecord(tBxRecord));
    }

    /**
     * 修改慢性报销管理
     */
//    @PreAuthorize("@ss.hasPermi('system:record:edit')")
    @Log(title = "慢性报销管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBxRecord tBxRecord) {
        return toAjax(tBxRecordService.updateTBxRecord(tBxRecord));
    }

    /**
     * 删除慢性报销管理
     */
    @PreAuthorize("@ss.hasPermi('system:record:remove')")
    @Log(title = "慢性报销管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tBxRecordService.deleteTBxRecordByIds(ids));
    }
}
